package proxy;

import java.io.IOException;

import org.apache.http.io.SessionInputBuffer;
import org.apache.http.io.SessionOutputBuffer;

public class TransferToServer extends Thread{
	private SessionInputBuffer in = null;
	private SessionOutputBuffer out = null;
	HttpSession session = null;
	
	public TransferToServer(SessionInputBuffer in, SessionOutputBuffer out){
		this.in = in;
		this.out = out;
	}
	
	public void run(){
		int reading = -1;
		byte[] buffered = new byte[8192];
		while (true){
			try {
				reading = in.read(buffered, 0, buffered.length);
				if (reading == -1){
					break;
				}
				out.write(buffered, 0, reading);
				out.flush();
			} catch (IOException e) {
				//e.printStackTrace();
				try {
					out.flush();
				} catch (IOException e1) {
				}
				break;
			}
		}
	}

}
